<%@page import="java.sql.*,java.io.*,java.util.*" language="java"%>
<%@page import="com.course.dbutil.DBConnectionFactory"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<body bgcolor="">


<jsp:include page="Header.jsp"></jsp:include>

<center><font color="#4D88DB"><h2>Your Exam Result</h2></font></center>



<%
try
        {

DBConnectionFactory ad=new DBConnectionFactory();
      Connection con1=ad.getConnection();
String status="False";
String qno[]=request.getParameterValues("qno");
int count=0;
%>
<table align="center" border=1><tr><th><b><font color="">QuestionNo</th><th><b><font color="">YourAnswer</th><th><b><font color="">CorrectAnswer</th><th><b><font color="">Status</th></tr>
<%
if(qno!=null)
{
for(int i=1;i<=qno.length;i++)
{
String ans=request.getParameter(""+i);
Statement st=con1.createStatement();
ResultSet rs=st.executeQuery("select CORRECTANS from question where qno ="+qno[i-1]);
if(rs.next())
{
String correct=rs.getString(1);
if(ans!=null)
{
if(ans.equals(correct))
{
count++;
status="True";
}
else
{
status="False";
}
}
else
{
continue;
}
%><tr><td align="center"><font color=""><%=qno[i-1] %></font></td><td><font color=""><%=ans%></font></td><td><font color=""><%=correct %></font></td><td><font color=""><%=status %></font></td></tr>
<%
}


}}



PreparedStatement ps=con1.prepareStatement("insert into marks values(?,?,(select sysdate from dual))");
ps.setInt(1,count);
ps.setString(2,(String)session.getAttribute("user"));
ps.executeUpdate();
%>
<font color="#000099"><b><%out.println("Your Score :"+count);%></b></font> 

<%

}
 
catch(Exception e){e.printStackTrace();}
 %></table>
 <br/>
 <jsp:include page="Footer.jsp"></jsp:include>
